import com.ktjy.kuozhan.SimpleFactory;
import com.ktjy.entity.Coffee;

import java.util.Scanner;

public class CoffeeStore {
    public static void main(String[] args) throws Exception {
//        Scanner input=new Scanner(System.in);
//        System.out.println("请输入你要点的咖啡：1.美式咖啡 2.拿铁咖啡");
//        int num=input.nextInt();
//
//        Coffee coffee= SimpleFactory.createCoffee(num);
//
//        System.out.println("客户点的咖啡是："+coffee.getName());
//        coffee.addMilk();
//        coffee.addSugar();

//        Scanner input=new Scanner(System.in);
//        System.out.println("请输入你要点的咖啡：1.美式咖啡 2.拿铁咖啡");
//        int num=input.nextInt();
//        Coffee coffee=null;
//        CoffeeFactory factory=null;
//        if(num==1){
//            factory=new AmericanCoffeeFactory();
//            coffee=factory.createCoffee();
//        }else if(num==2){
//            factory=new LatteCoffeeFactory();
//            coffee=factory.createCoffee();
//        }
//
//        System.out.println("客户点的咖啡是："+coffee.getName());
//        coffee.addMilk();
//        coffee.addSugar();

        Scanner input=new Scanner(System.in);
        System.out.println("请输入你要点的咖啡：1.美式咖啡 2.拿铁咖啡");
        int num=input.nextInt();
        Coffee coffee=null;
        if(num==1){
            coffee= (Coffee) SimpleFactory.getBean("americanCoffee");
        }else if(num==2){
            coffee=  (Coffee) SimpleFactory.getBean("latteCoffee");
        }
        System.out.println("客户点的咖啡是："+coffee.getName());
        coffee.addMilk();
        coffee.addSugar();
    }
}
